<?php

require_once 'Zend/View/Helper/Abstract.php';

class Core_View_Helper_Admin_RenderPublishedPagesList extends Zend_View_Helper_Abstract
{
    public function renderPublishedPagesList($publishLevel = null, $id = 'pagesList', $order = null, $limit = null, $offset = null)
    {
        $mdlPage = new Model_Page();
        $pages = $mdlPage->getPagesByPublishState($publishLevel, $order, $limit, $offset);

        if (is_array($pages)) {
            $xhtml = '<ul id="' . $id . '">';

            foreach ($pages as $pageId) {
                $page = new Model_Page();
                $title = $page->getPageTitle($pageId);

                $xhtml .= '<li class="page">' . $this->view->link($title, '/admin/page/edit/id/' . $pageId, 'page.png') . '</li>'. PHP_EOL;
            }
            $xhtml .= '</ul>' . PHP_EOL;

            return $xhtml;
        }
        return null;
    }
}